<!DOCTYPE html>
<html>

<head>
    <title>登录-半天妖管理系统</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/css/login.css?v=${constants.getReleaseVersion()}" media="all">
    <style>
        body{
            background: url("https://www.bantianyaozg.com/file/images/bg.jpg?v=${constants.getReleaseVersion()}") no-repeat center center;
            background-size: cover;
        }
        .layui-form-select{
            width: 100%;
        }
        /*.login-header {*/
        /*    color: rgba(0, 0, 0, .85) !important;*/
        /*}*/

        /*!*.login-footer {*!*/
        /*!*    color: rgba(0, 0, 0, 0.7) !important;*!*/
        /*!*}*!*/

        /*.login-footer a {*/
        /*    color: rgba(0, 0, 0, 0.7) !important;*/
        /*}*/

        /*.login-footer a:hover {*/
        /*    color: rgba(0, 0, 0, 0.4) !important;*/
        /*}*/
    </style>
    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>

<body>
<div class="login-wrapper">

<!--    <div class="login-header text-white">-->
<!--        <h4>让组织里的每个成员，长处发挥的淋漓尽致，短处变得无关紧要</h4>-->
<!--    </div>-->

    <div class=" login-body">
        <div class="layui-card yuzh">
            <h1>半天妖管理系统</h1>
            <div class="layui-card-header" style="text-align: center">
                <h2 style="font-weight: 700">注册</h2>
                <p style="font-size: 14px;line-height: 10px;color: red">（注：非公司员工无法注册）</p>
            </div>
            <div class="layui-card-body layui-form layui-form-pane" lay-filter="loginForm">
                <div class="layui-form-item">
                    <label class="layui-form-label">账  号</label>
                    <div class="layui-input-block">
                        <input name="account" id="account" placeholder="请输入帐号" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓  名</label>
                    <div class="layui-input-block">
                        <input name="name" id="name" placeholder="请输入姓名" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密  码</label>
                    <div class="layui-input-block">
                        <input name="password"  id="password" placeholder="请输入密码" type="password" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="overflow: inherit;">确认密码</label>
                    <div class="layui-input-block" >
                        <input name="confirmPassword"  id="confirmPassword" placeholder="请再次输入密码" type="password" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-block">
                        <input name="phone"  id="phone" placeholder="请输入手机号" type="text" lay-verify="required" class="layui-input" maxlength="11" oninput = "value=value.replace(/[^\d]/g,'')" >
                    </div>
                </div>
                <div class="layui-form-item" style="">
                    <label class="layui-form-label">角  色</label>
                    <div class="layui-input-block">
                        <select name="roleIds" lay-filter="roleIds" id="roleIds" lay-verify="required"
                                lay-search="roleIds">
                            <option value="">请选择角色</option>
                            <option value="1305313791343853569">开发人员</option>
                            <option value="1305422111420379138">开发总监</option>
                            <option value="1305422420779659266">工程总监</option>
                            <option value="1305422678196678657">营运总监</option>
                            <option value="1308249608428101633">营运经理</option>
                            <option value="1283292980305018882">督导</option>
                            <option value="1307580056085250050">网上建店负责人</option>
                            <option value="1308687414966087681">工程部</option>
                            <option value="1314441729702100993">供应链</option>
                            <option value="1293016774334623746">店长</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-xs3" style="padding-right: 10px">
                        <button  class="layui-btn" id="goback" style="background-color: #eeeeee;color: black">返 回</button>
                    </div>
                    <div class="layui-col-xs9">
                        <button  class="layui-btn layui-btn-fluid" lay-submit id="submit">注 册</button>
                    </div>
                </div>

            </div>
        </div>
    </div>

</div>

@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "${ctxPath}",
        version: '${constants.getReleaseVersion()}'
    };
</script>
<script src="https://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>


<script>
    function IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }

    var flag = IsPC();
    // if(flag === true){
        // var linkNode = document.createElement("link");
        // linkNode.setAttribute("rel","stylesheet");
        // linkNode.setAttribute("type","text/css");
        // linkNode.setAttribute("href","${ctxPath}/assets/common/css/login.css?v=${constants.getReleaseVersion()}");
        // document.head.appendChild(linkNode);
        // $('body').addClass('step');
        // $('body').removeClass("Mobile");
        // console.log("pc端");
    // }else{
        // var linkNode = document.createElement("link");
        // linkNode.setAttribute("rel","stylesheet");
        // linkNode.setAttribute("type","text/css");
        // linkNode.setAttribute("href","${ctxPath}/assets/common/css/loginMobile.css?v=${constants.getReleaseVersion()}");
        // document.head.appendChild(linkNode);
        // $('body').addClass('Mobile');
        // $('body').removeClass("step");
        // $('.login-header').hide();
        // console.log("移动端")
    // }


    $('body').height($('body')[0].clientHeight);

    layui.use(['layer', 'form', 'index', 'ax'], function () {
        var $ = layui.jquery;
        var $ax = layui.ax;
        var layer = layui.layer;
        var index = layui.index;

        //注册
        $('#submit').click(function () {
            var ajax = new $ax(Feng.ctxPath + "/register", function (data) {
                if(data.success==true){
                    Feng.success("注册成功!!!");
                    index.clearTabCache();
                    window.location.href = Feng.ctxPath + "/";
                }else {
                    Feng.error(data.message);
                }

            }, function (data) {
                layer.msg("注册失败！" + data.responseJSON.message, {icon: 5, anim: 6});
            });

            ajax.set("account", $("#account").val());
            ajax.set("name", $("#name").val());
            ajax.set("password", $("#password").val());
            ajax.set("confirmPassword", $("#confirmPassword").val());
            ajax.set("phone", $("#phone").val());
            ajax.set("roleIds", $("#roleIds").val());

            ajax.start();
        });

        // 返回
        $('#goback').click(function () {
            window.location.href = Feng.ctxPath + "/";
        })
    });
</script>
</body>
</html>